<?
$tmppath="../../";
REQUIRE($tmppath."protect/connect.php");

SWITCH ($choix){
    CASE 'u':
        $query1="SELECT unite_id, unite_user, unite_loc_x, unite_sloc,unite_loc_y FROM sdunite WHERE unite_id=$unit";
        //0= ID 1=User 2=loc 3=sloc
        $resultat1=mysql_query($query1);
        $tmp1=mysql_fetch_row($resultat1);
            $_SESSION_VAR_UNITE=$tmp1[0];
             SESSION_REGISTER("_SESSION_VAR_UNITE");

           $locx=$tmp1[2];
           $locy=$tmp1[4];

        IF ($tmp1[3]=='v'){
           $query1="SELECT  ville_loc_x, ville_loc_y FROM SDville WHERE ville_id=$tmp1[2]";
           //0= ID 1=User 2=loc
           $resultat1=mysql_query($query1);
           $tmp2=mysql_fetch_row($resultat1);
           $locx=$tmp2[0];
           $locy=$tmp2[1];

        }


         //************************************
         //Updater l'emplacement du user

         $query="UPDATE sduser_perso SET perso_loc_x=$locx,perso_loc_y=$locy where perso_id=$tmp1[1]";
         $resultat=mysql_query($query);
         $_SESSION_VAR_TERRE_X=$locx;
         SESSION_REGISTER("_SESSION_VAR_TERRE_X");
         $_SESSION_VAR_TERRE_Y=$locy;
         SESSION_REGISTER("_SESSION_VAR_TERRE_Y");
    
    
    BREAK;
       CASE 'v':
           $query1="SELECT ville_id, ville_proprio, ville_loc_x, ville_loc_y FROM sdville WHERE ville_id=$ville";
          //0= ID 1=User 2=loc
          $resultat1=mysql_query($query1);
          $tmp1=mysql_fetch_row($resultat1);

         //Updater l'emplacement du user
         $query="UPDATE sduser_perso SET perso_loc_x=$tmp1[2],perso_loc_y=$tmp1[3] where perso_id=$tmp1[1]";
         $resultat=mysql_query($query);
         
         
        BREAK;
       CASE 'b':

           $query1="SELECT batiment_loc,batiment_user FROM sdbatiment WHERE batiment_id=$batiment";
            echo $query;
              //0= ID 1=User 2=loc
           $resultat1=mysql_query($query1);
           $tmp2=mysql_fetch_row($resultat1);
           $loc=$tmp2[0];

         //************************************
         //Updater l'emplacement du user

         $query="UPDATE sduser_perso SET perso_loc='$loc' where perso_id=$tmp2[1]";
         echo $query;
         $resultat=mysql_query($query);



    BREAK;





}





mysql_close();
        //
$message="<a href=\"../map/indexmap.php?$SID \" target=\"main\">Cliquez ici</div></a>";
REQUIRE("indexmap.php");
exit;






?>
